package com.guodi.model.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guodi.model.entity.IdtWarnRule;
import com.guodi.model.mapper.IdtWarnRuleMapper;
import com.guodi.model.service.IIdtWarnRuleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @描述：指标预警规则表 服务类
 * @作者: 戴伙进
 * @日期: 2020-06-11
 */
@Service
public class IdtWarnRuleServiceImpl extends ServiceImpl<IdtWarnRuleMapper, IdtWarnRule> implements IIdtWarnRuleService {

    @Resource
    private IdtWarnRuleMapper idtWarnRuleMapper;

    @Override
    public IdtWarnRule listWarnRuleById(String indicatorsId) {
        return idtWarnRuleMapper.listWarnRuleById(indicatorsId);
    }

    /**
     * @描述: 获取预警规则集合
     * @入参:
     * @出参:
     * @作者: 汤厚韬
     * @日期: 2021/1/25 16:50
     **/
    @Override
    public Map<String, IdtWarnRule> getWarnRuleMap() {
        Map<String, IdtWarnRule> map = new HashMap<>();
        List<IdtWarnRule> list = super.list();
        for (IdtWarnRule idtWarnRule : list) {
            map.put(idtWarnRule.getName(), idtWarnRule);
        }
        return map;
    }

    @Override
    public Map<String, String> getWarnRuleMapById() {
        Map<String, String> map = new HashMap<>();
        List<IdtWarnRule> list = super.list();
        for (IdtWarnRule idtWarnRule : list) {
            map.put(idtWarnRule.getId(), idtWarnRule.getName());
        }
        return map;
    }
}
